<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" />
</head>
<body>
<form class="layui-form" id="user-add"  action="" lay-filter="add">
    <div class="layui-form-item">
        <label class="layui-form-label">用户编号：</label>
        <div class="layui-input-inline layui-col-md7">
            <input type="text" name="puser" id="puser"    lay-verify="required" placeholder="请输入用户编号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-inline layui-col-md1">
            <input type="text" name="ppassword" id="ppassword"    lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名：</label>
        <div class="layui-input-inline layui-col-md2">
            <input type="text" name="pname" id="pname"    lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="pphone" id="pphone"    lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="pemail" id="pemail"  lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别：</label>
        <div class="layui-input-block">
            <input type="radio" name="psex" value="男"  checked="checked">男
            <input type="radio" name="psex" value="女" >女
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="paddress"  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">注册时间：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="ptime"   id="ptime"  lay-verify="required" placeholder="请输入注册时间" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-inline layui-col-md3">
            <select name="pstatus">
                <option value="0">正常</option>
                <option value="1">封禁</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">治疗医生：</label>
        <div class="layui-input-inline layui-col-md3">
            <select id="did" name="did">
                <option value=""></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>


    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        //动态选择医生下拉列表
        $.ajax({
            url: "/queryDoctorAll.do",
            dataType: "json",
            success:function (rs) {
                console.log(rs);
                if (rs.code==0){
                    console.log(rs);
                    $.each(rs.data, function (index, item) {
                        // 追加option节点
                        //item.name是option里的文本值
                        //item.id是option的value值
                        $("#did").append(new Option(item.dname, item.did));
                    });
                    form.render('select');
                }
            }
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("add");
            console.log(data1);
            $.ajax({
                type:'post',
                url:'/insert.do',
                data:data1,
                dataType:"json",
                success:function (da) {
                    console.log(da);
                    if (da.code == 0) {
                        layer.alert("添加成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                            layer.msg("添加成功！");
                        })
                    } else {
                        layer.msg("添加失败！");
                    }
                }
            });
            return false;
        });
        laydate.render({
            elem: '#ptime'    //指定元素test1
        });
    });
</script>
</html>